#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n;
ll W, H;
ll a[N], num;
struct Node {
  ll x, y, v;
  bool operator<(const Node& o) const {
    if (y != o.y)
      return y < o.y;
    else
      return v < o.v;
  }
} lines[N];
ll mx[N << 2], tag[N << 2];
void build(int p, int l, int r) {
  if (l == r) {
    mx[p] = tag[p] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
}
void addtag(ll d, int p) {
  mx[p] += d;
  tag[p] += d;
}
void pushup(int p) { mx[p] = max(mx[p << 1], mx[p << 1 | 1]) + tag[p]; }
void update(int L, int R, ll d, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(d, p);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, d, p << 1, l, mid);
  if (R > mid) update(L, R, d, p << 1 | 1, mid + 1, r);
  pushup(p);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n >> W >> H) {
    rep(i, 1, n) {
      ll x, y, v;
      cin >> x >> y >> v;
      a[i] = x;
      lines[i] = {x, y, v};
      lines[i + n] = {x, y + H, -v};
    }
    sort(a + 1, a + n + 1);
    num = unique(a + 1, a + n + 1) - a - 1;
    build(1, 1, num);
    sort(lines + 1, lines + n * 2 + 1);
    ll ans = 0;
    rep(i, 1, n * 2) {
      int R = lower_bound(a + 1, a + num + 1, lines[i].x) - a;
      int L = upper_bound(a + 1, a + num + 1, lines[i].x - W) - a;
      update(L, R, lines[i].v, 1, 1, num);
      ans = max(ans, mx[1]);
    }
    cout << ans << endl;
  }
  return 0;
}